package leetCode;

public class GuiBingSort {
    public static void guibingSort(int nums[],int L,int R){
        int mid=(L+R)/2;
        if(L==R){
            return;
        }
        guibingSort(nums,L,mid);
        guibingSort(nums,mid+1,R);
        merge(nums,L,mid,R);
    }
    public static void merge(int nums[],int L,int mid,int R){
        int help[]=new int[R-L+1];
        int i=0;
        int p1=L;
        int p2=mid+1;
        while(p1<=mid&&p2<=R){
            help[i++]=nums[p1]<=nums[p2]?nums[p1++]:nums[p2++];
        }
        while(p1<=mid){
            help[i++]=nums[p1++];
        }
        while(p2<=R){
            help[i++]=nums[p2++];
        }
        for(i=0;i<help.length;i++){
            nums[L+i]=help[i];
        }
    }
}
